<template>
    <div id="GerritReviewDetail">
        <el-row>
            <el-col :xs="24" :sm="24" :lg="24" class="primary">代码评审详情页{{ title }}</el-col>
        </el-row>
        <hr>


        <el-row>
            <el-col :xs="24" :sm="24" :lg="24">
                <div class="ibox">
                    <div class="ibox-title">
                    <h5>Patch详情</h5> 
                    </div>
                    <div class="ibox-content">
                        <el-table
                            :data="tableData"
                            style="width: 100%">
                            <el-table-column prop="updatetime" label="日期" min-width="100" fixed></el-table-column>
                            <el-table-column prop="number" min-width="" label="提交单号"></el-table-column>
                            <el-table-column prop="subject" min-width="300" label="标题"></el-table-column>
                            <el-table-column prop="branch" min-width="150" label="分支"></el-table-column>
                            <el-table-column prop="component" min-width="130" label="模块名称"></el-table-column>
                            <el-table-column prop="owner" min-width="100" label="所有者"></el-table-column>
                            <el-table-column prop="line_insert" min-width="" label="代码新增"></el-table-column>
                            <el-table-column prop="line_delete" min-width="" label="代码删除"></el-table-column>
                            <el-table-column prop="inline_comments" min-width="" label="行内注释"></el-table-column>
                            <el-table-column fixed="right" label="操作" width="100">
                                <template slot-scope="sub">
                                    <el-button type="text" size="small" @click="goto_url_blank(sub.row.gerrit_url)">查看详情</el-button>
                                </template>
                            </el-table-column>
                        </el-table>
                        <el-pagination
                            style="padding-top: 10px;"
                            background
                            @current-change="handleCurrentChange"
                            :current-page="currentPage"
                            layout="total, prev, pager, next, jumper"
                            :total="total">
                        </el-pagination>
                    </div>
                </div>
            </el-col>
        </el-row>

        
    </div>
    
</template>
<script>
import { getHeader } from '@/app.config'

export default {
    name: 'GerritReviewDetail',
    components: {
    },
    props: {
        
    },
    data() {
        return {
            tableData: [],
            currentPage: 1,
            total: 0,
            project: '',
            title: '',
        }
    },
    created: function() {
        let query = this.$route.query;
        this.project = query.projectId;
        this.time = query.time;
        console.log(this.project, this.time)
    },
    methods: {
        getNoCommentPatch: function(project, time, page) {
            var source = process.env.VUE_APP_KANBAN_HOST + '/api/qa/projnoinlinecommentpatch?projectId=';
            source = source+project+'&time='+time+'&page='+page;
            this.$axios.get(source, {headers: getHeader()})
                .then((response) => {
                    if (response.status == 200) {
                        this.tableData = response.data.no_comment_patch;
                        this.total = response.data.count;
                    }
                })
                .catch(function(err) {
                    // eslint-disable-next-line
                    console.log(err);
                });
        },
        getData: function(page) {
            this.getNoCommentPatch(this.project, this.time, this.currentPage);
        },
        handleCurrentChange(val) {
            console.log(`当前页: ${val}`);
            this.currentPage = val;
            this.getData(this.currentPage);
        },
        goto_url_blank(gerrit_url) {
            if (gerrit_url) {
                var url = gerrit_url;            
                window.open(url, "_blank");
            }
        },
    },
    mounted: function() {
        this.getData(this.currentPage);
    },
    computed: {
        titled() {
            if (this.mode == 'patch_without_inline_c') {
                return ' - 无行内注释Patch(新增代码大于100行)';
            } else {
                return '';
            }
        }
    }
}
</script>

<style lang="scss" scoped>
    @import '../../assets/common/common.scss';
    #GerritReviewDetail{
        padding: 32px;
        background-color: rgb(240, 242, 245);
        position: relative;
    }
    .border{
        box-sizing: content-box;
        height: 0;
        overflow: visible;
        margin-top: 1rem;
        margin-bottom: 1rem;
        border: 0;
        border-top: 1px solid rgba(0,0,0,.1);
    }
    .primary{
        color: #409EFF;
        font-size: 30px;
        margin-top: 20px;
        margin-bottom: 10px;
        font-weight: 400;
    }
    .bgColor{
        background: #fff;
    }
    .pad{
        padding: 0 20px;
        padding-top: 20px;
    }
    .marT{
        margin-top: 20px;
    }
    .mar{
        margin: 0 20px;
        margin-top: 20px;
    }
    .table{
        padding-bottom: 10px;
    }
    #GerrirReview >>> .el-card{
        border: 0;
    }
</style>

